fix(ruby): adjust specifity of word characters - #336
AlternateRT wants to merge 1 commit into
Conversation
Only treat `!` and `?` as word characters when used in identifiers, symbols, hash key symbols, or the `defined?` method
vitallium
left a comment
There was a problem hiding this comment.
Looks great! I left just one suggestion about extending the capture to support more scenarios. Happy to hear your thoughts.
Side note: I think we have an issue with our CI configuration, as I’m pretty sure the changes in this PR should cause our snapshot tests to fail.
| [ | ||
| (identifier) | ||
| (simple_symbol) | ||
| (hash_key_symbol) | ||
| "defined?" | ||
| ] @identifier |
There was a problem hiding this comment.
suggestion: should we also add delimited_symbol and bare_symbol to handle use cases like :"ready?" or symbol arrays?
There was a problem hiding this comment.
I actually left those out intentionally.
Delimited symbols and symbol arrays allow you to use any arbitrary non-alphabetic character (e.g. :"symbol-with-dashes! and spaces?") as well as string interpolation - none of those will be treated as word characters, which is why I don't think we should give special treatment to ! and ? in this situation
After all, you won't be able to select the entire symbol with a double click like you would with a non-delimited one.
Only treat
!and?as word characters when used in identifiers, symbols, hash key symbols, or thedefined?method